package com.cndw.kungfu.model.queue;

import com.cndw.kungfu.config.ConstantsIntKey;
import com.cndw.kungfu.domain.Player;
import com.cndw.kungfu.domain.Queue;
import com.cndw.kungfu.model.Context;
import com.cndw.kungfu.vo.PlayerChangeVO;

/**
 * 执行队列任务的函数
 * 循环执行的函数  只输入每次执行的代码
 * 
 * 下次执行时间不规则的队列 在运行函数中 设置 nextExecTime
 * 
 * @author fantadust [9677889@qq.com]
 * @date 2011-8-25 下午3:11:15
 */
public class QueueFunc {

	/**
	 * 学习到技能
	 * 
	 * @param queue
	 */
	public static boolean studySkill(Queue queue) {
		
		int skillId = queue.getParam1();
		Context.getSkillServer().studySkill(queue.getPlayerId(), skillId);
		return true;
	}
	
	public static boolean studyGest(Queue queue){
		Context.getDiscipleServer().studyGest(queue.getPlayerId(),queue.getParam1(),queue.getParam2());
		
		return true;
	}
	
	public static boolean studyMarryTree(Queue queue){
		
		Player player = Context.getPlayerServer().getByPlayerId(queue.getPlayerId());
		player.getDataInfo().intDataSet(ConstantsIntKey.xl, queue.getParam1());
		player.getDataInfo().commitSync();
		player.clacProperties();
		player.commitSync();
		if (queue.getParam2() == 1) {
			Context.getPlayerServer().change(PlayerChangeVO.PLAYER_MAIN, player.toPlayerVO(), player.getPlayerId());
		}
		
		return true;
	}	
}
